package logic

import (
	"context"

	"cloud-disk/core/internal/svc"
	"cloud-disk/core/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserFileNameUpdateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserFileNameUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserFileNameUpdateLogic {
	return &UserFileNameUpdateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserFileNameUpdateLogic) UserFileNameUpdate(req *types.UserFileNameUpdateRequest, userIdentity string) (resp *types.UserFileNameUpdateResponse, err error) {
	resp = new(types.UserFileNameUpdateResponse)
	err = l.svcCtx.UserRepostioryModel.UpdateFileNameByIdentity(req.Identity, userIdentity, req.Name)
	if err != nil {
		resp.Message = "更新失败 " + err.Error()
		resp.Code = 100
		return resp, nil
	}

	resp.Message = "更新成功"
	resp.Code = 200
	return resp, nil
}
